package com.atguigu.eduservice.service.impl;





import com.atguigu.eduservice.entity.bo.UserListBO;
import com.atguigu.eduservice.mapper.UserListMapper;
import com.atguigu.eduservice.service.UserListService;

import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @author zhl
 * @create 2021/9/7 13:50
 */
@Transactional(readOnly = false)
@Service("userListService")
@AllArgsConstructor
public class UserListServiceImpl implements UserListService {

    //@Autowired
    //private UserListMapper  userListMapper;
   final UserListMapper userListMapper;
    //final com.atguigu.msmservice.mapper.UserListMapper UserListMapper;



    @Override
    public
    UserListBO getUserInfoByUser(String user) {
        UserListBO userListBO = userListMapper.getUserInfoByUser(user);
        if (userListBO != null) {
            List<String> list = userListMapper.getCustomerIdByUserId(userListBO.getId());
            userListBO.setCustomerId(StringUtils.join(list, ","));

        }
        return userListBO;
    }


    @Override
    public List<UserListBO> getUserList(UserListBO bo) {

        List<UserListBO> userListBOList = userListMapper.getUserList(bo);
        for (UserListBO userListBO : userListBOList) {
            List<String> menuList = userListMapper.getCustomerIdByUserId(userListBO.getId());
            userListBO.setCustomerId(StringUtils.join(menuList, ","));
        }
        return userListBOList;
    }


}
